﻿using BootstrapBlazor.Components;
using System.ComponentModel.DataAnnotations;
using TrackSystem.Entities.Extensions;

namespace TrackSystem.Entities.Dtos.Var
{
    public class VarDto
    {
        /// <summary>
        /// ID
        /// </summary>
        [Display(Name = "ID")]
        [AutoGenerateColumn(Order = 1)]
        public int Id { get; set; }

        /// <summary>
        /// 通道名称
        /// </summary>
        [Required]
        [Display(Name = "变量名称")]
        [AutoGenerateColumn(Order = 10, Filterable = true, Searchable = true, Sortable = true)]
        public required string Name { get; set; }

        /// <summary>
        /// 变量描述
        /// </summary>
        [Display(Name = "传感器描述")]
        [AutoGenerateColumn(Order = 15, Filterable = true, Searchable = true, Sortable = true)]
        public string? Description { get; set; }

        /// <summary>
        /// 变量类型
        /// </summary>
        [Required]
        [Display(Name = "变量类型")]
        [AutoGenerateColumn(Order = 20)]
        public VarSerialEnum Serial { get; set; }

        /// <summary>
        /// 寄存器变量，关联的传感器或者回路ID
        /// </summary>
        [Display(Name = "传感器ID")]
        [AutoGenerateColumn(Order = 30)]
        public int snrloopId { get; set; }

        /// <summary>
        /// 在传感器或者回路中的序号
        /// </summary>
        [Display(Name = "寄存器序号")]
        [AutoGenerateColumn(Order = 40)]
        public int snrloopIndex { get; set; }

        /// <summary>
        /// 读写属性 ture 只读  false 读写
        ///  只读，变量的值来源于内部计算
        /// </summary>
        [Display(Name = "只读属性")]
        [AutoGenerateColumn(Order = 60)]
        public bool ReadOnly { get; set; }

        /// <summary>
        /// 数据类型 b - 位  i-整数  f-浮点 
        /// </summary>
        [Display(Name = "数据类型")]
        [AutoGenerateColumn(Order = 70)]
        public DataTypeEnum DataType { get; set; }

        /// <summary>
        /// 初始值设定，只有在读写的自定义变量中用到
        /// </summary>
        [Display(Name = "初始值")]
        [AutoGenerateColumn(Order = 80)]
        public string? InitValue { get; set; }

        /// <summary>
        /// 自定义变量，关联的计算公式
        /// </summary>
        [Display(Name = "计算公式")]
        [AutoGenerateColumn(Order = 90)]
        public string? ClacuateFormula { get; set; }

        /// <summary>
        /// 是否需要记录
        /// </summary>
        [Display(Name = "记录")]
        [AutoGenerateColumn(Order = 100)]
        public bool IsRecord { get; set; }

        /// <summary>
        /// 记录周期 取100ms的整数倍
        /// </summary>
        [Display(Name = "记录周期")]
        [AutoGenerateColumn(Order = 110)]
        public int RecordCycle { get; set; }

        /// <summary>
        /// 是否需要报警 0-不报警 1-高报警 2-低报警 3-高低报警
        /// </summary>
        [Display(Name = "报警设置")]
        [AutoGenerateColumn(Order = 120)]
        public AlarmTypeEnum AlarmSetting { get; set; }

        /// <summary>
        /// 高报警
        /// </summary>
        [Display(Name = "高报值")]
        [AutoGenerateColumn(Order = 130)]
        public int HighAlarmSet { get; set; }

        /// <summary>
        /// 低报警
        /// </summary>
        [Display(Name = "低报值")]
        [AutoGenerateColumn(Order = 140)]
        public int LowAlarmSet { get; set; }
    }
}
